﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
namespace TerryDong.Data
{
    public class XmlContext<T> //: IDataContext<T>
    {
        XmlDocument _doc = null;
        string _filePath = string.Empty;

        private static XmlContext<T> instance = null;

        private XmlContext(string filePath)
        {
            _filePath = filePath;
            _doc = new XmlDocument();
            _doc.Load(filePath);
        }

        public static XmlContext<T> CreateInstance(string filePath)
        {

            if (instance == null)
            {
                instance = new XmlContext<T>(filePath);
            }
            else
            {
                if (instance._filePath!=filePath)
                {
                    instance = new XmlContext<T>(filePath);
                }
            }
            return instance;
        }


    }
}
